'''
----封装案例：学生类----
编写一个学生类：
属性：姓名、性别、类别默认为people
方法：hello
封装属性：年龄
增加方法：显示年龄、设置年龄
'''

#
# class Student:
#     category = 'people'
#
#     def __init__(self, name, sex, age):
#         self.name = name
#         self.sex = sex
#         self.__age = age
#
#     def hello(self):
#         print(f'大家好，我叫{self.name}')
#
#     def set_age(self, age):
#         if age >= 0 and age <= 200:
#             self.__age = age
#
#     def get_age(self):
#         if self.sex != '女':
#             return self.__age
#         else:
#             return '女生年龄保密'
#
# ammy = Student('ammy','女',18)
# # print(ammy.__age) # 无法在外边通过对象直接访问 私有属性
# print(ammy.get_age())
#
# tom = Student('ammy','男',20)
# print(tom.get_age())
'''
----案例：QQ群类----
编写一个QQ群类：
属性：群号、群名、成员、群暗号
方法：显示群号、显示群名、显示群成员、出示群暗号、添加群成员、移除群成员
'''

# class Qq:
#     def __init__(self, id, name, member, signal):
#         self.id = id
#         self.name = name
#         self.member = member
#         self.signal = signal
#
#     def get_id(self):
#         return self.id
#
#     def get_name(self):
#         return self.name
#
#     def get_member(self):
#         return self.member
#
#     def show_signal(self):
#         top = 0
#         pwd = input('请出示暗号')
#         if pwd == self.signal:
#             top = 1
#         return top
#
#     def add_member(self, new_member):
#         top = self.show_signal
#         if top == 1:
#             name = input('请输入新成员名字：')
#             self.member.append(name)
#         print(self.member)
#
#     def del_member(self):
#         mog = 0
#         top = self.show_signal
#         if top == 1:
#             name = input('请输入要移除成员')
#             for member in self.member:
#                 if name == member:
#                     msg = 1
#                     self.member.remove(member)
#                     print(self.member)
#             if mog == 0:
#                 print('成员不存在')
#
#
# if __name__ == '__main__':
#     qq1 = Qq(110, '懒人', ['zhang', 'wang'], '123')
#
#     print(qq1.get_id())
#     print(qq1.get_name())
#     print(qq1.get_member())
#     print(qq1.show_signal())
#     qq1.add_member()
#     qq1.del_member()
'''
----案例：银行卡类----
编写一个银行卡类：
属性：银行名称、卡号、密码、姓名、余额
方法：登录、存款、取款
'''

# class Card:
#     card_name = '中国银行'
#
#     def __init__(self, id, name,passwrd,balance):
#         self.id = id
#         self.name = name
#         self.password = passwrd
#         self.balance = balance
#
#     def assert(self):
#         top = 0
#         name = input('请输入id:')
#         pwd = input('请输入密码：')
#         if name == self.name and pwd == self.password:
#             top = 1
#         return top
#     def take_money(self):
#         top = self.assert()
#         if top ==1:
#             money = input('请输入存款金额')
#             self.balance += money
#             print(f'你的账户余额为：{self.balance}')
#     def monder(self):
#         top = self.assert()
#         if top == 1:
#             money = float(input('请输入取款金额'))
#             if money <= self.balance:
#                 self.balance -= money
#                 print(f'取款成功,余额{self.balance}')
#             else:
#                 print('余额不足')
# if __name__ == '__main__':
#      card1 = Card('101','xiaozhao','123','100')
# print(card1.assert())
# card1.take_money()
# card1.monder()
'''
----无人新零售----
随着无人新零售经济的崛起，商场、车站、大厦等各种场所都引入了无人饮品自动售货机，方便人们选购自己想要的饮品。
购买者选择想要的饮品，通过投币或扫码的方式支付，支付成功后从出货口取出饮品。
本案例要求编写代码，利用函数实现具有显示饮品信息、计算销售总额等功能的程序。

# 饮品信息 可以字典存储
goods = {'可口可乐': 2.5, '百事可乐': 2.5, '冰红茶': 3, '脉动': 3.5}
'''
# 饮品信息 可以列表嵌套字典存储
goods1 = {'id': '1001', 'name': '可口可乐', 'price': 2.5}
goods2 = {'id': '1002', 'name': '冰红茶', 'price': 3}
goods3 = {'id': '1003', 'name': '脉动', 'price': 3.5}
goods_list = [goods1, goods2, goods3]


class VendingMachine:
    def __init__(self, goods_list):
        self.goods_list = goods_list
        self.total_sales = 0

    def show_goods(self):
        for self.goods_list in goods_list:
            print(f'商品ID为：goods_list["id"], 商品名称为：goods_list["name"], 商品价格为：goods_list["price"]')

    def purchase_goods(self):
        top = 0

    for goods in goods_list:
        goods_id = input('请输入商品id')
        if goods_list[0][id] == goods_id:
            top = 1
        print(f'选择成功请支付方式(1现金,2扫码)：')
        money = float(input('请支付金额'))
        goods_list['price'] <= money
        print(f'支付成功,请取走商品')
        purchase_goods += money
    else:
        print('商品id不存在')

    def salesvolume(self):
        top = self.purchase_goods()
        purchase_goods = self.purchase_goods


if __name__ == '__main__':
    git = VendingMachine(goods_list)
    git.show_goods()
    git.purchase_goods()
    git.salesvolume()
